package com.motion.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.generator.config.rules.IColumnType;
import com.motion.dto.NavigationDto;
import com.motion.dto.insertNavigationDto;
import com.motion.generator.entity.Action;
import com.motion.generator.entity.Article;
import com.motion.generator.entity.Navigation;
import com.motion.generator.mapper.NavigationMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NavigationService {
    @Autowired(required = false)
    NavigationMapper navigationMapper;

    //分页查询 ，page是页数， size是页的大小
    public List<Navigation> cheak(Long page, Long size){
        //条件构造器
        QueryWrapper queryWrapper = new QueryWrapper();
        List<Navigation> ref = navigationMapper.selectPage(new Page<>(page,size),queryWrapper).getRecords();
        return ref;
    }

    public Navigation insertNavigation(Navigation navigation){
        navigationMapper.insert(navigation);
        return navigation;
    }

    public int delectNavigation(Long navigationId){
        return navigationMapper.deleteById(navigationId);
    }

    public  Navigation insertNavigationDto(Navigation navigation){
        navigationMapper.insert(navigation);
        return navigation;
    }

    public Navigation updateNavigation(Navigation navigation){
        navigationMapper.updateById(navigation);
        return navigationMapper.selectById(navigation);
    }

}
